package com.taijia.chapter9;

/**
 * Created with IntelliJ IDEA.
 * User: taijia
 * Date: 2015/2/3
 * Time: 22:06
 * To change this template use File | Settings | File Templates.
 */
public class TestYield {
    public static void main(String[] args) {
        Thread t1 = new MyThread3("t1");
        Thread t2 = new MyThread3("t2");
        t1.start();
        t2.start();
    }
}

class MyThread3 extends Thread {
    MyThread3(String s) {
        super(s);
    }

    @Override
    public void run() {
        for (int i = 1; i <= 100; i++) {
            System.out.println("I am " + getName() + ":" + i);
            if(0 == i%10)
                yield();
        }
    }
}
